package com.jinke.uang.model;

import com.jinke.uang.BuildConfig;
import com.jinke.uang.common.UserInfo;
import com.jinke.uang.constant.HttpConstant;
import com.jinke.uang.http.ModelUtils;
import com.jinke.uang.http.ParamsFactory;
import com.jinke.uang.http.RetrofitManager;
import com.jinke.uang.interfaces.ICommonModule;
import com.jinke.uang.interfaces.ICommonView;

import java.util.HashMap;
import java.util.Map;

/**
 * 作者：Song Shuyu
 * 时间：2019/4/11 13:37
 * package is com.jinke.uang.model
 * 还款相关的网络请求数据
 */
public class RepaymentModule implements ICommonModule{

    @Override
    public void getData(ICommonView view, int apiType,String listType, Object[] t) {
        Map<String, Object> formMap = new HashMap<>();
        switch (apiType) {

            case HttpConstant.ROLLOVER_PAY_CODE_DATA://有利息的还款码
                formMap.clear();
                formMap.put("orderId", String.valueOf(t[0]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getRolloverPayCodeData
                        (BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(formMap)), view, apiType, listType,t);
                break;

            case HttpConstant.PAY_CODE_DATA://还款码
                formMap.clear();
                formMap.put("orderId", String.valueOf(t[0]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getPayCodeData
                        (BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(formMap)), view, apiType, listType,t);
                break;
            case HttpConstant.OPEN_EXTENSION:  //是否开启展期
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().openExtension
                        (BuildConfig.channel, UserInfo.getToken(), ParamsFactory.getCommonParams(null)), view, apiType, listType,t);
                break;

            case HttpConstant.ORDER_DATA: //根据多个订单类型获取数据
                formMap.clear();
                formMap.put("type",String.valueOf(t[0]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getOrderData(BuildConfig.channel, UserInfo.getToken(),
                        ParamsFactory.getCommonParams(formMap)), view, apiType, listType,t);
                break;

            case HttpConstant.CALCULATED_ROLL_OVER_DATA: //展期数据计算接口
                formMap.clear();
                formMap.put("orderId", String.valueOf(t[0]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getCalculatedRollOverData(BuildConfig.channel, UserInfo.getToken(),
                        ParamsFactory.getCommonParams(formMap)), view, apiType, listType,t);
                break;

            default:
                break;
        }
    }
}
